/**
 * Project Name:mauto-web
 * File Name:TaskController.java
 * Package Name:com.inftech.mauto.core.web.front
 * Date:2016年11月10日上午11:19:39
 * Copyright (c) 2016, inf-technology Co., Ltd. All Rights Reserved.
 *
*/

package com.inftech.mauto.common.base;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;

import com.inftech.mauto.core.service.EnquiryService;
import com.inftech.mauto.core.service.OrderService;

/**
 * ClassName:SpringTask <br/>
 * Function: 定时任务控制器. <br/>
 * Date: 2016年11月10日 上午11:19:39 <br/>
 * 
 * @author puyf
 * @version
 * @since JDK 1.7
 */
@Controller
public class SpringTask {

	/**
	 * 注入咨询业务层
	 */
	@Autowired
	protected EnquiryService enquiryService;

	/**
	 * 注入订单业务层
	 */
	@Autowired
	protected OrderService orderService;

	protected final Logger LOG = Logger.getLogger(this.getClass());

	/**
	 * 
	 * sendCommentUrl:每天上午10点推送车大夫咨询评价链接. <br/>
	 *
	 * @author puyf
	 * @since JDK 1.7
	 */
	@Scheduled(cron = "0 0 10 * * ?")
	public void sendCommentUrl() {
		try {
			enquiryService.sendCommentUrl();
		} catch (Exception e) {
			LOG.error("推送评价链接失败", e);
		}
	}

	/**
	 * 
	 * sendCommentUrl:每天下午5点推送预约消息. <br/>
	 *
	 * @author puyf
	 * @since JDK 1.7
	 */
	@Scheduled(cron = "0 0 17 * * ?")
	public void sendAppointmentMessage() {
		try {
			orderService.sendAppointmentMessage();
		} catch (Exception e) {
			LOG.error("推送预约消息失败", e);
		}
	}
}
